package com.example.star.service;

import com.example.star.entity.Perimeter;
import com.example.star.entity.Star;
import com.example.star.mapper.PerimeterMapper;
import com.example.star.mapper.StarMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PerimeterService {
    @Autowired
    private PerimeterMapper perimeterMapper;

    public void savePerimeter(Perimeter perimeter) {
        perimeterMapper.insertPerimeter(perimeter);
    }

    public List<Perimeter> getAllPerimeters() {
        return perimeterMapper.getAllPerimeters();
    }

    public List<Perimeter> getPerimetersByPage(int page, int size) {
        int offset = (page - 1) * size;
        return perimeterMapper.getPerimetersByPage(offset, size);
    }

    public int getTotalPerimeters() {
        return perimeterMapper.getTotalPerimeters();
    }

    public Perimeter getPerimeterById(int id) {
        return perimeterMapper.getPerimeterById(id);
    }

    public void updatePerimeter(Perimeter perimeter) {
        perimeterMapper.updatePerimeter(perimeter);
    }

    public void deletePerimeter(int id) {
        perimeterMapper.deletePerimeter(id);
    }
}